************************************************************************************
***This code replicates all figures for "Elite-led Mobilization and Gay Rights: 
****Dispelling the Myth of Mass Opinion Backlash************************************
************************************************************************************

*********************
****Chapter 2********
*********************

*******************************
*************Figure 2.1********
*******************************
use "/Users/tom/Dropbox/Backlash/book outline/Chapter 2/LGB opinion over time.dta"
**witha line at 50%**
twoway (connected ssmtherm year, lpat("-*") msize(small) text( 41 1992 "Thermometer")) (connected adopt year, lpat("longdash") msize(small) text( 58 2008 "Adoption") ) (connected antidisclaw year, lpat(shortdash) msize(small) text( 78 2005 "Nondiscrimination")) (connected marriage year, lpat(dash) msize(small) text( 35 2008 "Marriage")), leg(off) scheme(s1manual) xlab(1984(4)2018) xtit("") yline(50)

 
**without line at 50%**
twoway (connected ssmtherm year, lpat("-.") msize(small) text( 40 1989 "Thermometer")) (connected adopt year, lpat("longdash") msize(small) text( 35 2008 "Adoption")) (connected antidisclaw year, lpat(shortdash)  msize(small) text( 78 2005 "Nondiscrimination")) (connected marriage year, lpat(dash) msize(small) text( 58 2005 "Marriage")), leg(off) scheme(s1manual) xlab(1984(4)2018) xtit("")


*********************
****Chapter 3********
*********************

*******************************
*************Figure 3.1********
*******************************

label var group "group"
label define group 1 "High SDO" 2 "High ITT" 3 "Unsophisticated" 4 "Independents" 5 "Evangelicals" 6 "General Public"
label value group group

*************thermometer of gays and lesbians all groups
twoway (scatter dm group) (rspike lb dm group) (rspike ub dm group), ytitle("Thermometer Rating") title("Attitudes Toward Gays and Lesbians") xlabel(1 "High SDO" 2 "High ITT" 3 "Unsophisticated" 4 "Independents" 5 "Evangelicals" 6 "General Public") xtitle("") xla(`levels', valuelabel angle(45)) legend(off) scheme(s1mono) name(fig2)

*************gay marriage opinion all groups
twoway (scatter ddm group) (rspike llb ddm group) (rspike uub ddm group), ytitle("Gay Marriage Opinion") title("Favorability Toward Gay Marriage") xlabel(1 "High SDO" 2 "High ITT" 3 "Unsophisticated" 4 "Independents" 5 "Evangelicals" 6 "General Public") xtitle("") xla(`levels', valuelabel angle(45)) legend(off) scheme(s1mono) name(fig3)

*************importance of gay marriage all groups
twoway (scatter dddm group) (rspike lllb dddm group) (rspike uuub dddm group), ytitle("Level of Importance") title("Importance of Gay Marriage Opinion") xlabel(1 "High SDO" 2 "High ITT" 3 "Unsophisticated" 4 "Independents" 5 "Evangelicals" 6 "General Public") xtitle("") xla(`levels', valuelabel angle(45)) legend(off) scheme(s1mono) name(fig4)

graph combine fig3 fig4 fig2, b1title(Error bars represent 95% confidence intervals) altshrink imargin(b=2 t=2) r(1) scheme(s1mono)

graph display, ysize(5) xsize(10)

*****************************************************************************************
******************Figure 3.2, difference in means gay marriage, by condition***************
*****************************************************************************************

label var cond "cond"
label define cond 1 "Legislature" 2 "Parade" 3 "Court" 4 "Referenda" 
label value cond cond

*****SDO by cond
twoway (scatter sdodm cond) (rspike sdolb sdodm cond) (rspike sdoub sdodm cond), yline(0,lp(dash)) title("High SDO") xlabel(1 "Legislature" 2 "Parade" 3 "Court" 4 "Referenda") xla(`levels', valuelabel angle(45)) yscale(range(-1 1)) xtitle("") ylabel(#5) legend(off) scheme(s1mono) name(sdo)

*****ITT by cond
twoway (scatter ittdm cond) (rspike ittlb ittdm cond) (rspike ittub ittdm cond), yline(0,lp(dash)) title("High ITT") xlabel(1 "Legislature" 2 "Parade" 3 "Court" 4 "Referenda") xla(`levels', valuelabel angle(45)) yscale(range(-1 1)) xtitle("") ylabel(#5) legend(off) scheme(s1mono) name(itt)

******evangl by cond

twoway (scatter evdm cond) (rspike evlb evdm cond) (rspike evub evdm cond), yline(0,lp(dash)) title("Evangelicals") xlabel(1 "Legislature" 2 "Parade" 3 "Court" 4 "Referenda") xla(`levels', valuelabel angle(45)) yscale(range(-1 1)) xtitle("") ylabel(#5) legend(off) scheme(s1mono) name(evangel)

******general public by cond

twoway (scatter gpdm cond) (rspike gplb gpdm cond) (rspike gpub gpdm cond), yline(0,lp(dash)) title("General Public") xlabel(1 "Legislature" 2 "Parade" 3 "Court" 4 "Referenda") xla(`levels', valuelabel angle(45)) yscale(range(-1 1)) xtitle("") ylabel(#5) legend(off) scheme(s1mono) name(gp)

******unsoph by cond

twoway (scatter undm cond) (rspike unlb undm cond) (rspike unub undm cond), yline(0,lp(dash)) title("Unsophisticated") xlabel(1 "Legislature" 2 "Parade" 3 "Court" 4 "Referenda") xla(`levels', valuelabel angle(45)) yscale(range(-1 1)) xtitle("") ylabel(#5) legend(off) scheme(s1mono) name(un)

******mod by cond

twoway (scatter mdm cond) (rspike mlb mdm cond) (rspike mub mdm cond), yline(0,lp(dash)) title("Independents") xlabel(1 "Legislature" 2 "Parade" 3 "Court" 4 "Referenda") xla(`levels', valuelabel angle(45)) yscale(range(-1 1)) xtitle("") ylabel(#5) legend(off) scheme(s1mono) name(mod)

graph combine sdo itt evangel un mod gp, l1title(Difference in Means) b1title(Error bars represent 95% confidence intervals) scheme(s1mono)


*****************************************************************************
********Figure 3.3 difference in means for importance by condition************
*****************************************************************************

label var cond "cond"
label define cond 1 "Legislature" 2 "Parade" 3 "Court" 4 "Referenda" 
label value cond cond

*****SDO by cond
twoway (scatter sdodm cond) (rspike sdolb sdodm cond) (rspike sdoub sdodm cond), yline(0,lp(dash)) title("High SDO") xlabel(1 "Legislature" 2 "Parade" 3 "Court" 4 "Referenda") xla(`levels', valuelabel angle(45)) xtitle("") yscale(range(-1.5 1.5)) ylabel(#5) legend(off) scheme(s1mono) name(sdo)

*****ITT by cond
twoway (scatter ittdm cond) (rspike ittlb ittdm cond) (rspike ittub ittdm cond), yline(0,lp(dash)) title("High ITT") xlabel(1 "Legislature" 2 "Parade" 3 "Court" 4 "Referenda") xla(`levels', valuelabel angle(45)) xtitle("") yscale(range(-1.5 1.5)) ylabel(#5) legend(off) scheme(s1mono) name(itt)

******evangl by cond
twoway (scatter evdm cond) (rspike evlb evdm cond) (rspike evub evdm cond), yline(0,lp(dash)) title("Evangelicals") xlabel(1 "Legislature" 2 "Parade" 3 "Court" 4 "Referenda") xla(`levels', valuelabel angle(45)) xtitle("") yscale(range(-1.5 1.5)) ylabel(#5) legend(off) scheme(s1mono) name(evangel)

******general public by cond
twoway (scatter gpdm cond) (rspike gplb gpdm cond) (rspike gpub gpdm cond), yline(0,lp(dash)) title("General Public") xlabel(1 "Legislature" 2 "Parade" 3 "Court" 4 "Referenda") xla(`levels', valuelabel angle(45)) xtitle("") yscale(range(-1.5 1.5)) ylabel(#5) legend(off) scheme(s1mono) name(gp)

******unsoph by cond
twoway (scatter undm cond) (rspike unlb undm cond) (rspike unub undm cond), yline(0,lp(dash)) title("Unsophisticated") xlabel(1 "Legislature" 2 "Parade" 3 "Court" 4 "Referenda") xla(`levels', valuelabel angle(45)) xtitle("") yscale(range(-1.5 1.5)) ylabel(#5) legend(off) scheme(s1mono) name(un)

******mod by cond
twoway (scatter mdm cond) (rspike mlb mdm cond) (rspike mub mdm cond), yline(0,lp(dash)) title("Independents") xlabel(1 "Legislature" 2 "Parade" 3 "Court" 4 "Referenda") xla(`levels', valuelabel angle(45)) yscale(range(-1.5 1.5)) xtitle("") ylabel(#5) legend(off) scheme(s1mono) name(mod)

graph combine sdo itt evangel un mod gp, l1title(Difference in Means) b1title(Error bars represent 95% confidence intervals) scheme(s1mono)

************************************************************************
*******Figure 3.4, diff means comparisons for gay therm by condition****
************************************************************************

label var cond "cond"
label define cond 1 "Legislature" 2 "Parade" 3 "Court" 4 "Referenda" 
label value cond cond

*****SDO by cond
twoway (scatter sdodm cond) (rspike sdolb sdodm cond) (rspike sdoub sdodm cond), yline(0,lp(dash)) title("High SDO") xlabel(1 "Legislature" 2 "Parade" 3 "Court" 4 "Referenda") xla(`levels', valuelabel angle(45)) xtitle("") yscale(range(-20 20)) ylabel(#5) legend(off) scheme(s1mono) name(sdo)

*****ITT by cond
twoway (scatter ittdm cond) (rspike ittlb ittdm cond) (rspike ittub ittdm cond), yline(0,lp(dash)) title("High ITT") xlabel(1 "Legislature" 2 "Parade" 3 "Court" 4 "Referenda") xla(`levels', valuelabel angle(45)) xtitle("") yscale(range(-20 20)) ylabel(#5) legend(off) scheme(s1mono) name(itt)

******evangl by cond
twoway (scatter evdm cond) (rspike evlb evdm cond) (rspike evub evdm cond), yline(0,lp(dash)) title("Evangelicals") xlabel(1 "Legislature" 2 "Parade" 3 "Court" 4 "Referenda") xla(`levels', valuelabel angle(45)) xtitle("") yscale(range(-20 20)) ylabel(#5) legend(off) scheme(s1mono) name(evangel)

******general public by cond
twoway (scatter gpdm cond) (rspike gplb gpdm cond) (rspike gpub gpdm cond), yline(0,lp(dash)) title("General Public") xlabel(1 "Legislature" 2 "Parade" 3 "Court" 4 "Referenda") xla(`levels', valuelabel angle(45)) xtitle("") yscale(range(-20 20)) ylabel(#5) legend(off) scheme(s1mono) name(gp)

******unsophisticated by cond
twoway (scatter undm cond) (rspike unlb undm cond) (rspike unub undm cond), yline(0,lp(dash)) title("Unsophisticated") xlabel(1 "Legislature" 2 "Parade" 3 "Court" 4 "Referenda") xla(`levels', valuelabel angle(45)) xtitle("") yscale(range(-20 20)) ylabel(#5) legend(off) scheme(s1mono) name(un)

******moderate by cond
twoway (scatter mdm cond) (rspike mlb mdm cond) (rspike mub mdm cond), yline(0,lp(dash)) title("Independents") xlabel(1 "Legislature" 2 "Parade" 3 "Court" 4 "Referenda") xla(`levels', valuelabel angle(45)) yscale(range(-20 20)) xtitle("") ylabel(#5) legend(off) scheme(s1mono) name(mod)

graph combine sdo itt evangel un mod gp, l1title(Difference in Means) b1title(Error bars represent 95% confidence intervals) scheme(s1mono)



*********************
****Chapter 4********
*********************

*******************************
*************Figure 4.1********
*******************************

*******************************
*************Figure 4.2********
*******************************



******************************************************************
**********Figure 4.3, before and after Supreme Court rulings******
******************************************************************

label var group "group"
label define group 1 "High SDO" 2 "Unsophisticated" 3 "Independents" 4 "Evangelicals" 5 "General Public"
label value group group

******first gay therm
twoway (scatter dm group) (rspike lb dm group) (rspike ub dm group), xtitle("") yline(0,lp(dash)) yscale(range(-15 15)) ylabel(#5) title("Attitudes Toward Gays and Lesbians") xlabel(1 "High SDO" 2 "Unsophisticated" 3 "Independents" 4 "Evangelicals" 5 "General Public") xla(`levels', valuelabel angle(45)) legend(off) scheme(s1mono) name(gaytherm)
*****second gay mar
twoway (scatter ddm group) (rspike llb ddm group) (rspike uub ddm group),  xtitle("") yline(0,lp(dash)) yscale(range(-1 1)) ylabel(#5) title("Gay Marriage Opinion") xlabel(1 "High SDO" 2 "Unsophisticated" 3 "Independents" 4 "Evangelicals" 5 "General Public") xla(`levels', valuelabel angle(45)) legend(off) scheme(s1mono) name(gaymar)
*****third importance "intensity"
twoway (scatter dddm group) (rspike lllb dddm group) (rspike uuub dddm group), xtitle("") yline(0,lp(dash)) yscale(range(-2 2)) ylabel(#5) title("Intensity of Gay Marriage") xlabel(1 "High SDO" 2 "Unsophisticated" 3 "Independents" 4 "Evangelicals" 5 "General Public") xla(`levels', valuelabel angle(45)) legend(off) scheme(s1mono) name(importance)

graph combine gaymar importance gaytherm, l1title(Difference in Means) b1title(Error bars represent 95% confidence intervals) altshrink imargin(b=1 t=1) scheme(s1mono) row(1)

graph display, ysize(4) xsize(7)

*********************
***Figure 4.4******
*********************

**Bring in the data for figures
import excel "/Users/incantalupo/Dropbox/Backlash/book chapters/Chapter 4 Observational Evidence/ch4_figure_data.xlsx", sheet("Sheet1") firstrow clear

*fix diff-in-means to go in correct directions (wave2 - wave1)

replace dm_policy = (-1)*dm_policy
replace dm_therm = (-1)*dm_therm
replace dm_imp = (-1)*dm_imp

replace dm_vote = (-1)*dm_vote
replace dm_contribute = (-1)*dm_contribute
replace dm_write = (-1)*dm_write
replace dm_social = (-1)*dm_social
replace dm_meeting = (-1)*dm_meeting
replace dm_march = (-1)*dm_march

gen lb_policy = dm_policy - (1.96)*se_policy
gen ub_policy = dm_policy + (1.96)*se_policy

gen lb_therm = dm_therm - (1.96)*se_therm
gen ub_therm = dm_therm + (1.96)*se_therm

gen lb_imp = dm_imp - (1.96)*se_imp
gen ub_imp = dm_imp + (1.96)*se_imp

gen lb_vote = dm_vote - (1.96)*se_vote
gen ub_vote = dm_vote + (1.96)*se_vote

gen lb_contribute = dm_contribute - (1.96)*se_contribute
gen ub_contribute = dm_contribute + (1.96)*se_contribute

gen lb_write = dm_write - (1.96)*se_write
gen ub_write = dm_write + (1.96)*se_write

gen lb_social = dm_social - (1.96)*se_social
gen ub_social = dm_social + (1.96)*se_social

gen lb_meeting = dm_meeting - (1.96)*se_meeting
gen ub_meeting = dm_meeting + (1.96)*se_meeting

gen lb_march = dm_march - (1.96)*se_march
gen ub_march = dm_march + (1.96)*se_march

label var group_label "group_label"
label define group_label 2 "General Public" 3 "Unsophisticated" 4 "Independents" 5 "Strong Republican" 6 "Evangelical" 7 "High Threat" 
label value group_label group_label

*Makes some graphs*
twoway (scatter dm_policy group_label) (rspike lb_policy dm_policy group_label) (rspike ub_policy dm_policy group_label), yline(0,lp(dash)) ytitle("") title("Support for Gay Marriage") xlabel(2 "General Public" 3 "" 3 "Unsophisticated" 4 "Independents" 5 "Strong Republicans" 6 "Evangelicals" 7 "High Threat") xtitle("") xla(`levels', valuelabel angle(45)) legend(off) scheme(s1mono) name(fig2a)
twoway (scatter dm_therm group_label) (rspike lb_therm dm_therm group_label) (rspike ub_therm dm_therm group_label), yline(0,lp(dash)) ytitle("") title("Attitudes Towards Gays and Lesbians") xlabel(2 "General Public" 3 "" 3 "Unsophisticated" 4 "Independents" 5 "Strong Republicans" 6 "Evangelicals" 7 "High Threat") xtitle("") xla(`levels', valuelabel angle(45)) legend(off) scheme(s1mono) name(fig3)
twoway (scatter dm_imp group_label) (rspike lb_imp dm_imp group_label) (rspike ub_imp dm_imp group_label), yline(0,lp(dash)) ytitle("") title("Intensity of Feelings about Gay Marriage") xlabel(2 "General Public" 3 "" 3 "Unsophisticated" 4 "Independents" 5 "Strong Republicans" 6 "Evangelicals" 7 "High Threat") xtitle("") xla(`levels', valuelabel angle(45)) legend(off) scheme(s1mono) name(fig4)
graph combine fig2a fig3 fig4, b1title(Error bars represent 95% confidence intervals) ysize(4.5) xsize(8) scheme(s1mono) r(1) altshrink


twoway (scatter dm_vote group_label) (rspike lb_vote dm_vote group_label) (rspike ub_vote dm_vote group_label), yline(0,lp(dash)) ytitle("") title("Vote") xlabel(2 "General Public" 3 "" 3 "Unsophisticated" 4 "Independents" 5 "Strong Republicans" 6 "Evangelicals" 7 "High Threat") xtitle("") xla(`levels', valuelabel angle(45)) legend(off) scheme(s1mono) name(fig5)
twoway (scatter dm_contribute group_label) (rspike lb_contribute dm_contribute group_label) (rspike ub_contribute dm_contribute group_label), yline(0,lp(dash)) ytitle("") title("Contribute") xlabel(2 "General Public" 3 "" 3 "Unsophisticated" 4 "Independents" 5 "Strong Republicans" 6 "Evangelicals" 7 "High Threat") xtitle("") xla(`levels', valuelabel angle(45)) legend(off) scheme(s1mono) name(fig6)
twoway (scatter dm_write group_label) (rspike lb_write dm_write group_label) (rspike ub_write dm_write group_label), yline(0,lp(dash)) ytitle("") title("Write") xlabel(2 "General Public" 3 "" 3 "Unsophisticated" 4 "Independents" 5 "Strong Republicans" 6 "Evangelicals" 7 "High Threat") xtitle("") xla(`levels', valuelabel angle(45)) legend(off) scheme(s1mono) name(fig7)
twoway (scatter dm_social group_label) (rspike lb_social dm_social group_label) (rspike ub_social dm_social group_label), yline(0,lp(dash)) ytitle("") title("Social Media") xlabel(2 "General Public" 3 "" 3 "Unsophisticated" 4 "Independents" 5 "Strong Republicans" 6 "Evangelicals" 7 "High Threat") xtitle("") xla(`levels', valuelabel angle(45)) legend(off) scheme(s1mono) name(fig8)
twoway (scatter dm_meeting group_label) (rspike lb_meeting dm_meeting group_label) (rspike ub_meeting dm_meeting group_label), yline(0,lp(dash)) ytitle("") title("Meeting") xlabel(2 "General Public" 3 "" 3 "Unsophisticated" 4 "Independents" 5 "Strong Republicans" 6 "Evangelicals" 7 "High Threat") xtitle("") xla(`levels', valuelabel angle(45)) legend(off) scheme(s1mono) name(fig9)
twoway (scatter dm_march group_label) (rspike lb_march dm_march group_label) (rspike ub_march dm_march group_label), yline(0,lp(dash)) ytitle("") title("March") xlabel(2 "General Public" 3 "" 3 "Unsophisticated" 4 "Independents" 5 "Strong Republicans" 6 "Evangelicals" 7 "High Threat") xtitle("") xla(`levels', valuelabel angle(45)) legend(off) scheme(s1mono) name(fig10)
graph combine fig5 fig6 fig7 fig8 fig9 fig10, b1title(Error bars represent 95% confidence intervals) ysize(4.5) xsize(8) scheme(s1mono) r(1) altshrink


*******************************
*************Figure 4.5********
*******************************

**************************
*******Chapter 5**********
**************************


*******************************
*************Figure 5.1********
*******************************


*******************************
*************Figure 5.2 court v. parade********
*******************************

use "/Users/tom/Dropbox/Backlash/book outline/Chapter 5-Institutions/replication files/courtvparade2.18.16.dta"

label var group "group"
label define group 1 "General Public" 2 "Strong Democrat" 3 "Strong Republican"  
label value group group

*************thermometer of gays and lesbians 
twoway (scatter dm group) (rspike lb dm group) (rspike ub dm group), ytitle("Thermometer Rating") title("Attitudes Toward Gays and Lesbians") xlabel(1 "General Public" 2 "Strong Democrat" 3 "Strong Republican") yline(0,lp(dash)) xtitle("") xla(`levels', valuelabel angle(45)) yscale(range(-30 30)) ylabel(#5) legend(off) scheme(s1mono) name(fig2)

*************gay marriage opinion
twoway (scatter ddm group) (rspike llb ddm group) (rspike uub ddm group), ytitle("Gay Marriage Opinion") title("Favorability Toward Gay Marriage") xlabel(1 "General Public" 2 "Strong Democrat" 3 "Strong Republican") yline(0,lp(dash)) xtitle("") xla(`levels', valuelabel angle(45)) yscale(range(-1 1)) ylabel(#5) legend(off) scheme(s1mono) name(fig3)

*************importance of gay marriage 
twoway (scatter dddm group) (rspike lllb dddm group) (rspike uuub dddm group), ytitle("Level of Importance") title("Importance of Gay Marriage Opinion") xlabel(1 "General Public" 2 "Strong Democrat" 3 "Strong Republican") yline(0,lp(dash)) xtitle("") xla(`levels', valuelabel angle(45)) yscale(range(-3 3)) ylabel(#5) legend(off) scheme(s1mono) name(fig4)

graph combine fig3 fig4 fig2, b1title(Error bars represent 95% confidence intervals) altshrink imargin(b=2 t=2) r(1) scheme(s1mono)

graph display, ysize(5) xsize(10)

***********************************
**Figure 5.3***Legislature vs. Parade
***********************************
use "/Users/tom/Dropbox/backlash/book outline/Chapter 5-Institutions/replication files/legvparade2.18.16.dta"

label var group "group"
label define group 1 "General Public" 2 "Strong Democrat" 3 "Strong Republican"  
label value group group

*************thermometer of gays and lesbians 
twoway (scatter dm group) (rspike lb dm group) (rspike ub dm group), ytitle("Thermometer Rating") title("Attitudes Toward Gays and Lesbians") xlabel(1 "General Public" 2 "Strong Democrat" 3 "Strong Republican") yline(0,lp(dash)) xtitle("") xla(`levels', valuelabel angle(45)) yscale(range(-30 30)) ylabel(#5) legend(off) scheme(s1mono) name(fig2)

*************gay marriage opinion
twoway (scatter ddm group) (rspike llb ddm group) (rspike uub ddm group), ytitle("Gay Marriage Opinion") title("Favorability Toward Gay Marriage") xlabel(1 "General Public" 2 "Strong Democrat" 3 "Strong Republican") yline(0,lp(dash)) xtitle("") xla(`levels', valuelabel angle(45)) yscale(range(-1.5 1.5)) ylabel(#5) legend(off) scheme(s1mono) name(fig3)

*************importance of gay marriage 
twoway (scatter dddm group) (rspike lllb dddm group) (rspike uuub dddm group), ytitle("Level of Importance") title("Importance of Gay Marriage Opinion") xlabel(1 "General Public" 2 "Strong Democrat" 3 "Strong Republican") yline(0,lp(dash)) xtitle("") xla(`levels', valuelabel angle(45)) yscale(range(-3 3)) ylabel(#5) legend(off) scheme(s1mono) name(fig4)

graph combine fig3 fig4 fig2, b1title(Error bars represent 95% confidence intervals) altshrink imargin(b=2 t=2) r(1) scheme(s1mono)

graph display, ysize(5) xsize(10)




***********************************
*******Figure 5.4 Ref v Parade*****
***********************************

use "/Users/tom/Dropbox/Backlash/book outline/Chapter 5-Institutions/replication files/refvparade2.18.16.dta"

label var group "group"
label define group 1 "General Public" 2 "Strong Democrat" 3 "Strong Republican"  
label value group group

*************thermometer of gays and lesbians 
twoway (scatter dm group) (rspike lb dm group) (rspike ub dm group), ytitle("Thermometer Rating") title("Attitudes Toward Gays and Lesbians") xlabel(1 "General Public" 2 "Strong Democrat" 3 "Strong Republican") yline(0,lp(dash)) xtitle("") xla(`levels', valuelabel angle(45)) yscale(range(-30 30)) ylabel(#5) legend(off) scheme(s1mono) name(fig2)

*************gay marriage opinion
twoway (scatter ddm group) (rspike llb ddm group) (rspike uub ddm group), ytitle("Gay Marriage Opinion") title("Favorability Toward Gay Marriage") xlabel(1 "General Public" 2 "Strong Democrat" 3 "Strong Republican") yline(0,lp(dash)) xtitle("") xla(`levels', valuelabel angle(45)) yscale(range(-1 1)) ylabel(#5) legend(off) scheme(s1mono) name(fig3)

*************importance of gay marriage 
twoway (scatter dddm group) (rspike lllb dddm group) (rspike uuub dddm group), ytitle("Level of Importance") title("Importance of Gay Marriage Opinion") xlabel(1 "General Public" 2 "Strong Democrat" 3 "Strong Republican") yline(0,lp(dash)) xtitle("") xla(`levels', valuelabel angle(45)) yscale(range(-3 3)) ylabel(#5) legend(off) scheme(s1mono) name(fig4)

graph combine fig3 fig4 fig2, b1title(Error bars represent 95% confidence intervals) altshrink imargin(b=2 t=2) r(1) scheme(s1mono)

graph display, ysize(5) xsize(10)


****************************************************
************institutional decisions 2X3 figure 5.5**
****************************************************

use "/Users/tom/Dropbox/backlash/book outline/Chapter 5-Institutions/replication files/fig 5_4 institutions.dta"

*************thermometer of gays and lesbians 
twoway (scatter dm group) (rspike lb dm group) (rspike ub dm group), ytitle("Thermometer Rating") title("") yline(0,lp(dash)) xtitle("") xla(`levels', valuelabel angle(45)) yscale(range(-10 10)) ylabel(#5) legend(off) scheme(s1mono) name(fig2a)
twoway (scatter dm1 group) (rspike lb1 dm1 group) (rspike ub1 dm1 group), ytitle("") title("") yline(0,lp(dash)) xtitle("") xla(`levels', valuelabel angle(45)) yscale(range(-10 10)) ylabel(#5) legend(off) scheme(s1mono) name(fig2a1)
twoway (scatter dm2 group) (rspike lb2 dm2 group) (rspike ub2 dm2 group), ytitle("") title("") yline(0,lp(dash)) xtitle("") xla(`levels', valuelabel angle(45)) yscale(range(-10 10)) ylabel(#5) legend(off) scheme(s1mono) name(fig2a2)

graph combine fig2a fig2a1 fig2a2, title("Attitudes Toward Gays and Lesbians") altshrink imargin(b=2 t=2) r(1) scheme(s1mono) name(figx)

*************gay marriage opinion
twoway (scatter ddm group) (rspike llb ddm group) (rspike uub ddm group), ytitle("Gay Marriage Opinion") title("Referendum Change vs. Court Change") yline(0,lp(dash)) xtitle("") xla(`levels', valuelabel angle(45)) yscale(range(-.5 .5)) ylabel(#5) legend(off) scheme(s1mono) name(fig3a)
twoway (scatter ddm1 group) (rspike llb1 ddm1 group) (rspike uub1 ddm1 group), ytitle("") title("Referendum Change vs. Legislature Change") yline(0,lp(dash)) xtitle("") xla(`levels', valuelabel angle(45)) yscale(range(-.5 .5)) ylabel(#5) legend(off) scheme(s1mono) name(fig3a1)
twoway (scatter ddm2 group) (rspike llb2 ddm2 group) (rspike uub2 ddm2 group), ytitle("") title("Court Change vs. Legislature Change") yline(0,lp(dash)) xtitle("") xla(`levels', valuelabel angle(45)) yscale(range(-.5 .5)) ylabel(#5) legend(off) scheme(s1mono) name(fig3a2)

graph combine fig3a fig3a1 fig3a2, title("Favorability Toward Gay Marriage") altshrink imargin(b=2 t=2) r(1) scheme(s1mono) name(figy)

graph combine figy figx, r(3) altshrink imargin(b=2 t=2) r(1) scheme(s1mono)


*********************
****Chapter 7********
*********************


*********************
***Figure 7.3 code***
*********************
clear

use "/Users/tom/Dropbox/Backlash/book outline/Chapter 6 materials/Iowa_County_Retention_Data/Iowa_County_Working_Subset_File_2002and2010_combined.dta", replace

generate Turnoutx100=TotalTurnout * 100

generate ternus_rolloffx100=  ternus_rolloff *100

generate streit_rolloffx100=  streit_rolloff*100  

generate Evanpctx100=Evanpct*100

generate ternus_votex100=  Ternuspct*100

generate streit_votex100=  Streitpct*100  


reg ternus_rolloffx100 i.year Turnoutx100 Evanpctx100 year#c.Turnoutx100 year#c.Evanpctx100
margins, over(year) at(Evanpctx100=(0(5)40))
marginsplot, recast(line) recastci(rarea) legend(off)  xtitle(Percent Evangelical) text(17 30 "2010")  text(42 8 "2002")  ytitle(Ternus Roll-off) title("") graphregion(color(white)) name(ternusRO, replace)



reg streit_rolloffx100 i.year Turnoutx100 Evanpctx100 year#c.Turnoutx100 year#c.Evanpctx100
margins, over(year) at(Evanpctx100=(0(5)40))
marginsplot, recast(line) recastci(rarea) legend(off)  xtitle(Percent Evangelical) text(17 30 "2010")  text(42 8 "2002")  ytitle(Streit Roll-off) title("") graphregion(color(white)) name(streitRO, replace)


graph combine ternusRO streitRO, scheme(s1mono)
graph export "/Users/bishin/Dropbox/Backlash/book outline/chapter 6 materials/Chapter 7 Graphs/Figure 7-3 Roll Off by Evangelical.jpg", as(jpg) replace
 



*********************
***Figure 7.4 code***
*********************
clear 
use "/Users/tom/Dropbox/Backlash/book outline/Chapter 6 materials/Iowa_County_Retention_Data/Iowa_County_Working_Subset_File_2002and2010_combined.dta", replace

generate Turnoutx100=TotalTurnout * 100

generate ternus_votex100=  Ternuspct*100

generate streit_votex100=  Streitpct*100  

generate Evanpctx100=Evanpct*100
**********************
**Streit Vote***
reg streit_votex100 Obama2ptypct i.year Turnoutx100 Evanpctx100 year#c.Turnoutx100 year#c.Evanpctx100

margins, over(year) at(Evanpctx100=(0(5)40))
marginsplot, recast(line) recastci(rarea) legend(off)  xtitle(Percent Evangelical) text(45 35 "2010") text(80 5 "2002") ytitle(Streit Vote Share) title("") graphregion(color(white)) name(StreitEvan, replace)


***Ternus Vote***
reg ternus_votex100 Obama2ptypct i.year Turnoutx100 Evanpctx100 year#c.Turnoutx100 year#c.Evanpctx100


margins, over(year) at(Evanpctx100=(0(5)40))
marginsplot, recast(line) recastci(rarea) legend(off)  xtitle(Percent Evangelical) text(45 35 "2010") text(80 10 "2002")ytitle(Ternus Vote Share) title("") graphregion(color(white)) name(ternusEvan, replace)


***graph combine ternusEvan ternusTurnout StreitEvan StreitTurnout***
graph combine ternusEvan StreitEvan, scheme(s1mono)
 graph export "/Users/bishin/Dropbox/Backlash/book outline/chapter 6 materials/Chapter 7 Graphs/Figure 7-4 Vote Share by Evangelical.jpg", as(jpg) replace

*********************
***Figure 7.5 code***
*********************

clear
use  "/Users/tom/Dropbox/Backlash/book outline/Chapter 6 materials/Judicial spending data/Judicial_Election_Data_1_17.dta"

graph bar outStatepct if over1k==1, over(Iowa)  text(.42 23 "38.4%") text(.835 77 "82.2%")   scheme(s1mono) title("Money from Out of State") ytitle("") name(IowaDonpct, replace)
graph bar No_Against if over1k==1, over(Iowa) text(139 23 "135.92")  text(9 77 "5") scheme(s1mono) title("Avg. Number of Donors") ytitle("") name(IowaNumbdonations, replace)
graph bar avgcontsize if over1k==1, over(Iowa) text(45000 23 "$42,557") text ( 102000 77 "$99,551") scheme(s1mono) title("Avg. Contribution") ytitle("") name(Iowacontsize, replace)

graph combine  IowaDonpct IowaNumbdonations  Iowacontsize, row(1) scheme(s1mono)
 graph export "/Users/bishin/Dropbox/Backlash/book outline/chapter 6 materials/Chapter 7 Graphs/Figure 7-5 Money Donors Contribution Average.jpg", as(jpg) replace


*********************
***Figure 7.6 code***
*********************

********************************************************
**comparing just the Conlin race and the court race**
********************************************************

clear
use "/Users/tom/Dropbox/Backlash/book outline/Chapter 6 materials/Iowa_2010_non_judicial_spending_data/Iowa_2010_non_judicial_contribution_summary.dta", replace



graph bar pct_OOS , over(ConlinNaDum)   text(43 23 "40.4%")  text(101 77.5 "99.0%")  scheme(s1mono) title("Money from Out of State") ytitle("") name(ConOOSpct, replace)
graph bar No_Of_Conts , over(ConlinNaDum)  text(1650 22.5 "1,623") text(50 77.5 "6") scheme(s1mono) title("Number of Donors") ytitle("") name(Connoofconts, replace)
graph bar avg_cont , over(ConlinNaDum) text(171000 77.5 "$165,142") text( 10000 22.5 "$2,251")   scheme(s1mono) title("Avg. Contribution") ytitle("") name(Conavgcontsize, replace)

graph combine ConOOSpct Connoofconts Conavgcontsize, row(1) scheme(s1mono)
 graph export "/Users/bishin/Dropbox/Backlash/book outline/chapter 6 materials/Chapter 7 Graphs/Figure 7-6 Conlin vs Court Contributions.jpg", as(jpg) replace
 
 
 
*********************
***Figure 7.7 code***
*********************
 
********************************************************
**comparing just the Branstad race and the court race**
********************************************************
clear
use "/Users/tom/Dropbox/Backlash/book outline/Chapter 6 materials/Iowa_2010_non_judicial_spending_data/Iowa_2010_non_judicial_contribution_summary.dta", replace

graph bar pct_OOS , over(BranstadNaDum)   text(27 23 "24.5%")  text(101 77.5 "99.0%")  scheme(s1mono) title("Money from Out of State") ytitle("") name(BranOOSpct, replace)
graph bar No_Of_Conts , over(BranstadNaDum)  text(14500 22.5 "13,995") text(700 77.5 "6") scheme(s1mono) title("Number of Donors") ytitle("") name(Brannoofconts, replace)
graph bar avg_cont , over(BranstadNaDum) text(171000 77.5 "$165,142") text( 6000 22.5 "$630")   scheme(s1mono) title("Avg. Contribution") ytitle("") name(Branavgcontsize, replace)

graph combine BranOOSpct Brannoofconts Branavgcontsize, row(1) scheme(s1mono)
graph export "/Users/bishin/Dropbox/Backlash/book outline/chapter 6 materials/Chapter 7 Graphs/Figure 7-7 Branstad vs Court Contributions.jpg", as(jpg) replace
